package com.nbjtjc.safe.api.danger;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.danger.DangerSafePlanList;
import com.nbjtjc.safe.service.danger.DangerSafePlanListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther guqianbin
 * @date 2018/4/10 10:41
 * 隐患检查计划内的单挑计划的接口
 **/
@RestController
@RequestMapping("/danger/safePlanList")
@CrossOrigin("*")
public class DangerSafePlanListController {

    @Autowired
    private DangerSafePlanListService dangerSafePlanListService;

    @SysLog("添加检查计划中的一条记录")
    @RequestMapping(value = "/add", method = {RequestMethod.POST})
    public Result add(@RequestBody DangerSafePlanList dangerSafePlanList) {
        ValidatorUtils.validateEntity(dangerSafePlanList);
        Result result = dangerSafePlanListService.add(dangerSafePlanList);
        return result;
    }

    @SysLog("更新检查计划中的计划条例")
    @RequestMapping(value = "/update", method = {RequestMethod.POST})
    public Result update(@RequestBody DangerSafePlanList dangerSafePlanList) {
        ValidatorUtils.validateEntity(dangerSafePlanList, UpdateGroup.class);
        Result result = dangerSafePlanListService.update(dangerSafePlanList);
        return result;
    }

    @RequestMapping(value = "/find", method = {RequestMethod.POST})
    public Result find(@RequestBody DangerSafePlanList dangerSafePlanList) {
        Result result = dangerSafePlanListService.find(dangerSafePlanList);
        return result;
    }

    @SysLog("删除检查计划表的一条计划")
    @RequestMapping(value = "/delete", method = {RequestMethod.POST})
    public Result delete(@RequestBody DangerSafePlanList dangerSafePlanList) {
        ValidatorUtils.validateEntity(dangerSafePlanList, UpdateGroup.class);
        Result result = dangerSafePlanListService.delete(dangerSafePlanList);
        return result;
    }
}
